/**
 * 
 */
package test;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;

import javax.swing.JPanel;

/**
 * @author patrick
 *
 */
public class Board extends JPanel{

	/**
	 * generated
	 */
	private static final long serialVersionUID = 6184448745460380310L;

	/**
	 * 
	 */
	public Board() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * The painting is done inside the paint() method
	 * */
	public void paint(Graphics g){
		super.paint(g);
		
		//The Graphics2D object provides a sophisticated control over painting.
		Graphics2D g2d = (Graphics2D)g;
		
		
		//The rendering hints are used to make the drawing smooth.
		RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
		g2d.setRenderingHints(renderingHints);
		
		// We get the height and the width of the window.
		Dimension size = getSize();
		double w = size.getWidth();
		double h = size.getHeight();
		
		// Here we create the ellipse.
		Ellipse2D ellipse = new Ellipse2D.Double(0, 0, 80, 130);
		g2d.setStroke(new BasicStroke(1));
		g2d.setColor(Color.gray);
		
		//Here the ellispse is rotated 72 times to create a "donut".
		for(double deg = 0; deg < 360; deg +=5){
			AffineTransform at = AffineTransform.getTranslateInstance(w/2, h/2);
			at.rotate(Math.toRadians(deg));
			g2d.draw(at.createTransformedShape(ellipse));
		}
		
	}

}
